package com.example.modules.vo;

import com.example.modules.entity.Comment;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;

import java.util.Date;
import java.util.List;

@Data
@Builder
public class CommentVO {
    @ApiModelProperty("id")
    private Integer id;
    @ApiModelProperty("用户id")
    private Integer userId;
    @ApiModelProperty("帖子id")
    private Integer postId;
    @ApiModelProperty("父评论的用户id")
    private Integer parentUserId;
    @ApiModelProperty("父评论id")
    private Integer parentId;
    @ApiModelProperty("评论内容")
    private String content;
    @ApiModelProperty("评论时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date commentTime;
    private List<CommentVO> commentVOList;

    public static CommentVO of(Comment comment){
        CommentVO commentVO = CommentVO.builder().build();
        BeanUtils.copyProperties(comment,commentVO);
        return commentVO;
    }
}
